#ifndef CATANEXCEPTION_H_
#define CATANEXCEPTION_H_

#include <string>
#include <sstream>
#include <exception>

class CatanException : public std::exception
{
public:
	CatanException(const char* file, const int line, const char* type, const char* exceptionDescription);
	CatanException(const char* file, const int line, const char* type, const char* exceptionDescription, const CatanException &predecessor);
	virtual const char* what() const throw()
	{
		std::stringstream whatValue;
		whatValue << type << " at " << file << ":" << line << ": " << exceptionDescription;
		if (hasPredecessor)
		{
			whatValue << std::endl << "           " << predecessor->what();
		}
		return whatValue.str().c_str();
	}

private:
	const char* file;
	const int line;
	const char* type;
	const char* exceptionDescription;
	const bool hasPredecessor;
	const CatanException* predecessor;
};

#endif /*CATANEXCEPTION_H_*/
